/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mydatastore;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author DTIT
 */
public class MyDataStore {

    public static Connection getConnection() {
        Connection connection = null;
        try {
            connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/myweb?user=root&password=root");
        } catch (SQLException ex) {
            Logger.getLogger(MyDataStore.class.getName()).log(Level.SEVERE, null, ex);
        }
        return connection;
    }

    public static void close(ResultSet rs, Statement stmt,
            Connection con) {
        if (rs != null) {
            try {
                rs.close();
            } catch (SQLException e) {
            }
        }
        if (stmt != null) {
            try {
                stmt.close();
            } catch (SQLException e) {
            }
        }
        if (con != null) {
            try {
                con.close();
            } catch (SQLException e) {
            }
        }
    }
}
